func isPerfectSquare(num int) bool {
    left, right := 0, num/2 + 1
    
    for left <= right {
        middle := (left+right)/2
        squrt := middle*middle
        if squrt < num {
            left = middle + 1
        } else if squrt > num {
            right = middle - 1
        } else {
            return true
        }
    }
    return false
}
